package io.renren.modules.gis_admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.gis_admin.dao.MapLayersDao;
import io.renren.modules.gis_admin.dto.MapLayersDTO;
import io.renren.modules.gis_admin.entity.MapLayersEntity;
import io.renren.modules.gis_admin.service.MapLayersService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 图层管理
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2022-11-05
 */
@Service
public class MapLayersServiceImpl extends CrudServiceImpl<MapLayersDao, MapLayersEntity, MapLayersDTO> implements MapLayersService {

    @Override
    public QueryWrapper<MapLayersEntity> getWrapper(Map<String, Object> params) {
        QueryWrapper<MapLayersEntity> wrapper = new QueryWrapper<>();

        if (params != null && !params.isEmpty()) {
            String id = (String) params.get("id");
            String layerType = (String) params.get("layerType");
            String displayName = (String) params.get("displayName");
            String layerName = (String) params.get("layerName");
            wrapper.eq(StringUtils.isNotBlank(id), "id", id);
            wrapper.eq(StringUtils.isNotBlank(layerType), "layer_type", layerType);
            wrapper.like(StringUtils.isNotBlank(displayName), "display_name", displayName);
            wrapper.like(StringUtils.isNotBlank(layerName), "layer_name", layerName);
        }


        return wrapper;
    }


}